package com.hopes.bizz.risk.control.dto;

import com.hopes.bizz.risk.control.entity.RiskUnitEntity;
import com.hopes.boss.common.entity.BaseLogicEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.BeanUtils;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.List;

/**
 * @author daijie
 * @version 1.0
 * @date 2023/7/24 19:25
 * @Description:
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Schema(description = "风险分析单元DTO")
public class RiskUnitDTO extends BaseLogicEntity {

    private static final long serialVersionUID = 5383021492381155517L;

    public RiskUnitEntity toPO() {
        RiskUnitEntity entity = new RiskUnitEntity();
        BeanUtils.copyProperties(this, entity);

        if (!this.deptIdList.isEmpty()) {
            StringBuilder builder = new StringBuilder();
            for (Long id : this.deptIdList) {
                builder.append(id).append(",");
            }
            builder.deleteCharAt(builder.length() - 1);
            entity.setDeptId(builder.toString());
        }

//        if (!this.principalList.isEmpty()) {
//            StringBuilder builder = new StringBuilder();
//            for (Long id : this.principalList) {
//                builder.append(id).append(",");
//            }
//            builder.deleteCharAt(builder.length() - 1);
//            entity.setPrincipal(builder.toString());
//        }
        return entity;
    }

    private Long id;

    private Long riskObjectId;

    private Integer riskUnitType;

    private String riskName;

    private String riskCode;

    private List<Long> deptIdList;

    private String postId;

    private String principal;

    private String controlLevel;

    private String riskLocation;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date serviceDate;

    private String hazardDesc;

    private String emergencyDesc;

    private Boolean identifyFlag;

    private String identifyMethod;

    private String evaluateMethod;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date evaluateDate;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date reevaluateDate;

    private Long evaluateUserId;

    private Long identifyUserId;

    private Long auditUserId;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date auditDate;

    private String evaluateMember;

    private String longitude;

    private String latitude;

    private String altitude;

    private String areaScope;

    private String qrCode;

    private String nfcCode;

    private String remarks;

    private String img;

    private Boolean reportDataFlag;

    private Integer riskLevel;

    private Integer riskValue;

    private String riskDesc;

    private Integer afterRiskValue;

    private Integer afterRiskLevel;

    private String afterRiskDesc;

    private Long orgId;
}
